import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'layout',
    meta: {
      name: '首页'
    },
    redirect: '/login',
    component: () => import('@/views/background/Layout/index.vue'),
    children: [
      {
        path: '/home',
        name: 'home',
        meta: {
          name: '首页'
        },
        component: () => import('@/views/background/home/index.vue')
      },
      {
        path: '/foodManage',
        name: 'foodManage',
        meta: {
          name: '菜品管理'
        },
        component: () => import('@/views/background/foodManage/index.vue')
      },
      {
        path: '/inventoryManage',
        name: 'inventoryManage',
        meta: {
          name: '库存管理'
        },
        component: () => import("@/views/background/inventoryManage/index.vue")
      },
      {
        path: '/orderManage',
        name: 'orderManage',
        meta: {
          name: '订单管理'
        },
        component: () => import("@/views/background/orderManage/index.vue")
      },
      {
        path: '/orderDetail',
        name: 'orderDetail',
        meta: {
          name: '订单详情'
        },
        component: () => import("@/views/background/orderManage/detailPage.vue")

      },
      {
        path: '/merchantInfo',
        name: 'merchantInfo',
        meta: {
          name: '商家信息'
        },
        component: () => import("@/views/background/merchantInfo/index.vue")

      },
      {
        path: '/joinManage',
        name: 'joinManage',
        meta: {
          name: '入驻管理'
        },
        component: () => import("@/views/background/joinManage/index.vue")

      },
    ]
  },
  {
    path: '/orderHome',
    name: 'orderHome',
    meta: {
      name: '首页'
    },
    component: () => import("@/views/reception/Layout/index.vue"),
    redirect: "/orderHome/receptionHome",
    children: [
      {
        path: 'foodList',
        name: 'foodList',
        meta: {
          name: '菜品列表'
        },
        component: () => import("@/views/reception/foodList/index.vue")
      },
      {
        path: 'receptionHome',
        name: 'receptionHome',
        meta: {
          name: '首页'
        },
        component: () => import("@/views/reception/home/index.vue")
      },
      {
        path: 'business',
        name: 'business',
        meta: {
          name: '商家店铺'
        },
        component: () => import("@/views/reception/business/index.vue")
      },
      {
        path: 'submitOrder',
        name: 'submitOrder',
        meta: {
          name: '提交订单'
        },
        component: () => import("@/views/reception/submitOrder/index.vue")
      },
      {
        path: 'myCenter',
        name: 'myCenter',
        meta: {
          name: '个人中心'
        },
        component: () => import("@/views/reception/myCenter/index.vue")
      },
      {
        path: 'orderManage',
        name: 'orderManage',
        meta: {
          name: '订单管理'
        },
        component: () => import("@/views/reception/order/index.vue")
      },
      {
        path: 'myAdress',
        name: 'myAdress',
        meta: {
          name: '地址管理'
        },
        component: () => import("@/views/reception/myCenter/myAdress/index.vue")
      },
      {
        path: 'myInfo',
        name: 'myInfo',
        meta: {
          name: '地址管理'
        },
        component: () => import("@/views/reception/myCenter/myInfo/index.vue")
      },
      {
        path:'evaluate',
        name:'evaluate',
        meta:{
          name:'评价'
        },
        component: () => import("@/views/reception/evaluate/index.vue")

      },
      {
        path:'orderDetail',
        name:'orderDetail',
        meta:{
          name:'订单详情'
        },
        component: () => import("@/views/reception/orderDetail/index.vue")

      },
    ]
  },
  {
    path: '/receptionLogin',
    name: 'receptionLogin',
    meta: {
      name: '登录'
    },
    component: () => import("@/views/reception/login/index.vue")
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      name: '登录',
    },
    component: () => import('@/views/background/login/index.vue')

  }

]

const router = new VueRouter({
  routes
})

export default router
